package com.byl.modules.attachment;

import com.byl.common.modules.controller.BaseController;
import com.byl.sdk.utils.UploadUtils;
import com.byl.sdk.video.VideoUtils;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;
import javax.servlet.http.HttpServletRequest;

/**
 * Created by Administrator on 2019/9/24.
 */
@RestController
@RequestMapping("/attach")
public class UploadController extends BaseController {

    @PostMapping("/news/upload")
    String uploadnews(HttpServletRequest request, String type, @RequestPart MultipartFile file) {
        return UploadUtils.uploadImage(request,"news",file,250,150);
    }

    @PostMapping("/logo/upload")
    String uploadlogo(HttpServletRequest request, String type, @RequestPart MultipartFile file) {
        return UploadUtils.uploadImage(request,"logo",file,96,96);
    }

    @PostMapping("/project/upload")
    String uploadproject(HttpServletRequest request,  @RequestPart MultipartFile file) {
        return UploadUtils.uploadImage(request,"project",file,280,85);
    }

    @PostMapping("/ft/upload")
    String uploadft(HttpServletRequest request,  @RequestPart MultipartFile file) {
        return UploadUtils.uploadImage(request,"ft",file,520,340);
    }

    @PostMapping("/video/upload")
    String uploadvideo(HttpServletRequest request, @RequestPart MultipartFile file) {
        String path=UploadUtils.uploadFile(request,"video",file);
         VideoUtils.grap(request,path);
        return path;
    }

    @PostMapping("/banner/upload")
    String uploadBanner(HttpServletRequest request, int loc, @RequestPart MultipartFile file){
        String path="";
        //滚动banner
        if(loc==1){
            path=UploadUtils.uploadBanner(request,file,900,360,480,191);
        }else if(loc==2){
            //宣传语
            path=UploadUtils.uploadBanner(request,file,900,108,0,0);
        }else if(loc==3){
         //二级广告
            path=UploadUtils.uploadBanner(request,file,1200,250,0,0);
        }
        return path;
    }


}
